﻿using System.Windows;
using System.Windows.Controls;

namespace Com.Lancetinc.Evs.Reports.RadPdf;

internal class TextBlockRenderer : UIElementRendererBase
{
    internal override bool Render(UIElement element, PdfRenderContext context)
    {
        var textBlock = element as TextBlock;
        if (textBlock == null)
        {
            return false;
        }

        var text = textBlock.Text;
        var foreground = textBlock.Foreground;
        var width = textBlock.ActualWidth;
        var height = textBlock.ActualHeight;
        var fontFamily = textBlock.FontFamily;
        var fontSize = textBlock.FontSize;

        TextRenderer.DrawTextBlock(text, context, foreground, width, height, fontFamily, fontSize);

        return true;
    }
}